package org.hq.system.dao.impl;

import java.util.List;

import org.hq.system.dao.UserDao;
import org.hq.system.model.UserVO;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;


public class UserDaoImpl extends SqlMapClientDaoSupport implements UserDao {

	public List<UserVO> findUserList() throws Exception{
		return (List<UserVO>)getSqlMapClientTemplate().queryForList("userSqlMap.getUserList");
	}

	public UserVO findUserById(UserVO userVO) throws Exception {
		return (UserVO)getSqlMapClientTemplate().queryForObject("userSqlMap.getUserById",userVO);
	}

	public String saveUser(UserVO userVO) throws Exception {
		 getSqlMapClientTemplate().insert("userSqlMap.insertUser", userVO);
		return userVO.getUserId();
	}
	
	public void updateUser(UserVO userVO) throws Exception {
		getSqlMapClientTemplate().update("userSqlMap.updateUser", userVO);
	}

	public void updateUserLastLogin(UserVO userVO) throws Exception {
		getSqlMapClientTemplate().update("userSqlMap.updateUserLastLogin", userVO);
	}
	
	public int deleteUser(UserVO userVO) throws Exception {
		Object id = getSqlMapClientTemplate().delete("userSqlMap.deleteUser", userVO);
		return Integer.parseInt(id.toString());
	}

	
}
